public class PC {
    private CPU cpu; // CPU 对象
    private HardDisk hd; // HardDisk 对象

    public void setCPU(CPU c) {
        this.cpu = c;
    }

    public void setHardDisk(HardDisk h) {
        this.hd = h;
    }

    public void show() {
        if (cpu != null && hd != null) {
            System.out.printf("CPU Speed: %d MHz%n", cpu.getSpeed());
            System.out.printf("Hard Disk Capacity: %d GB%n", hd.getAmount());
        } else {
            System.out.println("CPU or Hard Disk not set.");
        }
    }

    @Override
    public String toString() {
        return String.format("PC [CPU: %s, Hard Disk: %s]", cpu, hd);
    }
}
